<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="frmTitle">
        <p:growl id="msgs" showDetail="false"/>
        <h:panelGrid columns="2" cellpadding="1">
            <h:outputText value="#{msgs.funcionarioTituloLista}" styleClass="fontTitle"/>
        </h:panelGrid>
    </h:form>
        
    <h:panelGrid columns="2" width="100%">
        
        <h:form id="frmSearch">
            
            <h:panelGrid columns="3">
                
                <p:commandLink id="refreshTable" actionListener="#{funcionarioMB.atualizarTabela}" title="#{msgs.btnAtualizar}"  update=":frmDataTable:tbl" >
                    <h:graphicImage value="img/refresh.png" style="border: 0" />
                </p:commandLink>
                    
                <p:inputText id="txtBusca" value="#{funcionarioMB.busca}" size="35" />
                <p:commandButton id="btnSearch" value="#{msgs.btnBuscar}" alt="#{msgs.btnBuscar}" title="#{msgs.btnBuscar}" actionListener="#{funcionarioMB.buscar}" icon="ui-icon ui-icon-search" update=":frmDataTable:tbl"/>
                    
            </h:panelGrid>
                
        </h:form>
            
    </h:panelGrid>

    <h:form id="frmDataTable">

        <p:fieldset legend="#{msgs.funcionarioLgdLista}">

            <h:panelGrid width="100%">            

                <p:dataTable id="tbl" var="tbl" paginator="true" paginatorPosition="bottom" rowsPerPageTemplate="5,10,15" rows="10"
                             emptyMessage="#{msgs.msgTabelaVazia}" value="#{funcionarioMB.lsfuncionario}">
                    <f:facet name="header">
                        <h:outputText value="#{msgs.funcionarioTblTitulo}"/>                    
                    </f:facet>
                       
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colNome}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.nome}"/>
                    </p:column>
                        
                        
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.login}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.login}"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.email}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.email}"/>
                    </p:column>
                      
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.departamento}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.departamento.descricao}"/>
                    </p:column>
                    
                     <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.cpf}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.cpf}"/>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colDtCriacao}"/>
                        </f:facet>
                        <h:outputText value="#{tbl.dtcriacao}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msgs.colStatus}"/>
                        </f:facet>
                        <h:outputText value="#{funcionarioMB.strStatusLabel(tbl.status)}"/>
                    </p:column>
                     
                    <p:column style="width:160px">
                        <p:commandButton id="btnVisualizar" alt="#{msgs.btnVisualizar}" title="#{msgs.btnVisualizar}" icon="ui-icon ui-icon-search" oncomplete="dlgVisualizar.show()" actionListener="#{funcionarioMB.visualizar(tbl)}" update=":frmVisualizar" />
                        <p:commandButton id="btnEditar"  alt="#{msgs.btnEditar}" title="#{msgs.btnEditar}" icon="ui-icon ui-icon-pencil" action="#{funcionarioMB.editar}" ajax="false" >
                            <f:param id="idfuncionario" name="idfuncionario" value="#{tbl.id}"/>
                        </p:commandButton>
                        <p:commandButton id="btnChangePassword" alt="#{msgs.alterarSenha}" title="#{msgs.alterarSenha}" icon="ui-icon ui-icon-key" oncomplete="dlgChangePassword.show()" actionListener="#{funcionarioMB.selecionarRegistro(tbl)}" />
                        <p:commandButton id="btnExcluir" alt="#{msgs.btnExcluir}" title="#{msgs.btnExcluir}" icon="ui-icon ui-icon-close" oncomplete="cfmDlgExcluir.show()" actionListener="#{funcionarioMB.selecionarRegistro(tbl)}" update=":frmExcluir"/>
                    </p:column>
                   
                </p:dataTable>
            
            </h:panelGrid>
        </p:fieldset>
    </h:form>
    
    <h:form id="frmVisualizar">

        <p:dialog header="#{msgs.visualizar}" widgetVar="dlgVisualizar" width="750"  resizable="false" modal="true" styleClass="styleDialog">

            <p:fieldset legend="#{msgs.alunosDlgLgdVisualizar}">

                <h:panelGrid columns="2">
                    
                    <h:outputLabel value="#{msgs.instituicao}: "/>
                    <h:outputText value="#{funcionarioMB.strinstituicao}"/>
                        
                    <h:outputLabel value="#{msgs.nome}: "/>
                    <h:outputText value="#{funcionarioMB.strnome}"/>
                    
                    <h:outputLabel value="#{msgs.email}: "/>
                    <h:outputText value="#{funcionarioMB.stremail}"/>
                    
                    <h:outputLabel value="#{msgs.login}: "/>
                    <h:outputText value="#{funcionarioMB.strlogin}"/>
                    
                    <h:outputLabel value="#{msgs.telefone}: "/>
                    <h:outputText value="#{funcionarioMB.strtelefone}"/>
                    
                    <h:outputLabel value="#{msgs.celular}: "/>
                    <h:outputText value="#{funcionarioMB.strcelular}"/>
               
                    <h:outputLabel value="#{msgs.campusLblTelefone}: "/>
                    <h:outputText value="#{funcionarioMB.strtelefone}"/>
                            
                    <h:outputLabel value="#{msgs.campusLblDtCriacao}: "/>
                    <h:outputText value="#{funcionarioMB.strdtcriacao}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                        
                    <h:outputLabel value="#{msgs.campusLblStatus}: "/>
                    <h:outputText value="#{funcionarioMB.strstatus}"/>                

                 </h:panelGrid>

            </p:fieldset>

            <p:commandButton style="width:90px;margin-bottom: 10px;margin-top: 10px;" value="#{msgs.btnFechar}" alt="#{msgs.btnFechar}" title="#{msgs.btnFechar}" onclick="dlgVisualizar.hide()" styleClass="centerButton"/>

        </p:dialog>

    </h:form>
    
    <h:form id="frmExcluir">

        <p:confirmDialog id="confirmDialogExcluir" header="#{msgs.funcionarioDlgTituloExcluir}" message=" #{msgs.dlgMsgExcluir} #{funcionarioMB.funcionarioselecionado.nome} ?"
                         width="300" height="60" severity="alert" widgetVar="cfmDlgExcluir">

            <p:commandButton value="#{msgs.btnSim}" oncomplete="cfmDlgExcluir.hide()" alt="#{msgs.btnSim}" title="#{msgs.btnSim}" actionListener="#{funcionarioMB.excluir}"
                             update=":frmTitle:msgs,:frmDataTable:tbl"/>
            <p:commandButton value="#{msgs.btnNao}" onclick="cfmDlgExcluir.hide()" alt="#{msgs.btnNao}" title="#{msgs.btnNao}" type="button"/>

        </p:confirmDialog>

    </h:form>
    
     <h:form id="frmChangePassword">

        <p:dialog header="#{msgs.alterarSenha}" widgetVar="dlgChangePassword" minHeight="175" width="414" resizable="false" modal="true" styleClass="styleDialog"  >

            <p:fieldset  legend="#{msgs.titleChangePasswordMessage}" >

                <h:panelGrid columns="1" width="100%">

                    <h:panelGrid columns="2">

                        <h:graphicImage value="img/key.png" style="margin-top: -10%"/>

                        <h:panelGrid columns="2">

                            <h:outputLabel for="txtNomeUsuario" value="#{msgs.usuario}"/>
                            <h:outputText id="txtNomeUsuario"  value="#{funcionarioMB.funcionarioselecionado.nome}"/>  

                            <h:outputLabel for="txtNewPassword" value="#{msgs.senha}"/>
                            <p:password id="txtNewPassword" feedback="true" value="#{funcionarioMB.senha}" maxlength="12" size="15" weakLabel="#{msgs.msmWeekLabel}" goodLabel="#{msgs.msmGoodLabel}" strongLabel="#{msgs.msmStrongLabel}"/>

                            <h:outputLabel for="txtConfirmPassword" value="#{msgs.confirmasenha}"/>
                            <p:password id="txtConfirmPassword" feedback="true" value="#{funcionarioMB.confirmasenha}" maxlength="12" size="15" promptLabel="#{msgs.msmPromptLabel}" weakLabel="#{msgs.msmWeekLabel}" goodLabel="#{msgs.msmGoodLabel}" strongLabel="#{msgs.msmStrongLabel}"/>

                        </h:panelGrid>

                    </h:panelGrid>

                </h:panelGrid>

            </p:fieldset>

            <h:panelGrid columns="2" style="margin-top: 1%">
                <p:commandButton style="width:90px ; margin-left: -2px" value="#{msgs.btnAlterar}" alt="#{msgs.btnAlterar}" title="#{msgs.btnAlterar}" onclick="dlgChangePassword.hide()" actionListener="#{funcionarioMB.alterarSenha}"
                                 update=":frmTitle:msgs,:frmDataTable:tbl"/>
                <p:commandButton style="width:90px" value="#{msgs.btnCancelar}" alt="#{msgs.btnCancelar}" title="#{msgs.btnCancelar}" onclick="dlgChangePassword.hide()"/>
            </h:panelGrid>

        </p:dialog>

    </h:form>
        
</html>

